﻿using BaseDao;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AMInstantMessagingServerDao
{
    public class UserService : BaseService<UserModel>
    {
        private UserProvider _UserProvider = new UserProvider();

        protected override IBaseProvider<UserModel> Provider => _UserProvider;

        /// <summary>
        /// 根据用户名获取用户
        /// </summary>
        /// <param name="user_name"></param>
        /// <returns></returns>
        public UserModel GetUserByUserName(string user_name)
        {
            return _UserProvider.GetUserByUserName(user_name);
        }

        /// <summary>
        /// 更具用户名获取Id
        /// </summary>
        /// <param name="user_name"></param>
        /// <returns></returns>
        public long GetUserIdByUserName(string user_name)
        {
            return _UserProvider.GetUserIdByUserName(user_name);
        }

        /// <summary>
        /// 根据Token获取Id
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public UserClientInfo GetClientInfoByToken(string token)
        {
            return _UserProvider.GetClientInfoByToken(token);
        }

        /// <summary>
        /// 设置Id跟Token
        /// </summary>
        /// <param name="id"></param>
        /// <param name="token"></param>
        public void SetClientInfoAndToken(UserClientInfo info, string token)
        {
            _UserProvider.SetClientInfoAndToken(info, token);
        }

        /// <summary>
        /// 根据小票生成客户端信息
        /// </summary>
        /// <param name="user_token"></param>
        /// <returns></returns>
        public bool RemoveClientInfoByToken(string user_token)
        {
            return _UserProvider.RemoveClientInfoByToken(user_token);
        }
    }
}
